﻿using System;
using System.Data;
using System.IO;
using System.Xml;
using System.Configuration;
using System.ComponentModel;
using System.Collections.Generic;

namespace GreatB2C.Config.SiteInfo
{
    public class IPConfig
    {
        #region IP段限制配置
        /// <summary>
        /// 全站来访限定方式
        /// </summary>
        public static string LockIPType
        {
            get
            {
                return BaseConfig.GetConfigValue( BaseConfig.eConfigs.IPLimit , "LockIPType" );
            }
            set
            {
                BaseConfig.SetConfigValue( BaseConfig.eConfigs.IPLimit , "LockIPType" , value );
            }
        }

        /// <summary>
        /// 全站IP段白名单
        /// </summary>
        public static string IPLockWhite
        {
            get
            {
                return BaseConfig.GetConfigValue( BaseConfig.eConfigs.IPLimit , "IPLockWhite" );
            }
            set
            {
                BaseConfig.SetConfigValue( BaseConfig.eConfigs.IPLimit , "IPLockWhite" , value );
            }
        }

        /// <summary>
        /// 全站IP段黑名单
        /// </summary>
        public static string IPLockBlack
        {
            get
            {
                return BaseConfig.GetConfigValue( BaseConfig.eConfigs.IPLimit , "IPLockBlack" );
            }
            set
            {
                BaseConfig.SetConfigValue( BaseConfig.eConfigs.IPLimit , "IPLockBlack" , value );
            }
        }

        /// <summary>
        /// 后台来访限定方式
        /// </summary>
        public static string AdminLockIPType
        {
            get
            {
                return BaseConfig.GetConfigValue( BaseConfig.eConfigs.IPLimit , "AdminLockIPType" );
            }
            set
            {
                BaseConfig.SetConfigValue( BaseConfig.eConfigs.IPLimit , "AdminLockIPType" , value );
            }
        }

        /// <summary>
        /// 后台IP段白名单
        /// </summary>
        public static string IPLockAdminWhite
        {
            get
            {
                return BaseConfig.GetConfigValue( BaseConfig.eConfigs.IPLimit , "IPLockAdminWhite" );
            }
            set
            {
                BaseConfig.SetConfigValue( BaseConfig.eConfigs.IPLimit , "IPLockAdminWhite" , value );
            }
        }

        /// <summary>
        /// 后台IP段黑名单
        /// </summary>
        public static string IPLockAdminBlack
        {
            get
            {
                return BaseConfig.GetConfigValue( BaseConfig.eConfigs.IPLimit , "IPLockAdminBlack" );
            }
            set
            {
                BaseConfig.SetConfigValue( BaseConfig.eConfigs.IPLimit , "IPLockAdminBlack" , value );
            }
        }

        public static bool Config( string LockIPType , string IPLockWhite , string IPLockBlack , string AdminLockIPType
            , string IPLockAdminWhite , string IPLockAdminBlack )
        {
            Dictionary<string , string> dicts = new Dictionary<string , string>( );

            dicts.Add( "LockIPType" , LockIPType );
            dicts.Add( "IPLockWhite" , IPLockWhite );
            dicts.Add( "IPLockBlack" , IPLockBlack );
            dicts.Add( "AdminLockIPType" , AdminLockIPType );
            dicts.Add( "IPLockAdminWhite" , IPLockAdminWhite );
            dicts.Add( "IPLockAdminBlack" , IPLockAdminBlack );

            return BaseConfig.SetConfigForBatch( BaseConfig.eConfigs.IPLimit , dicts );
        }
        #endregion
    }
}
